﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public partial class AWCDataContext
    {
        public IEnumerable<Address> GetStoreAddresses()
        {
            // !! REMEBER TO ASK IF MAIN OFFICE IS THE STORES REAL SHOPPING ADRESS!!!
            // Get all the addresses of the stores
            IEnumerable<Address> storeaddresses = (from s in Stores
                          join ca in CustomerAddresses
                          on s.CustomerID equals ca.CustomerID
                          where ca is CustomerAddress &&
                          /*AdressTypeID = main office */
                          (ca.AddressTypeID == 3  /*&& ca.Address.StateProvince.CountryRegion.Name != "USA"*/)
                          select ca.Address);
            return storeaddresses;

        }
        public IEnumerable<Address> GetStoreAddresses(CountryRegion countryRegion)
        {
            // !! REMEBER TO ASK IF MAIN OFFICE IS THE STORES REAL SHOPPING ADRESS!!!
            // Get all the addresses of the stores
            IEnumerable<Address> storeaddresses = (from s in Stores
                                                   join ca in CustomerAddresses
                                                   on s.CustomerID equals ca.CustomerID
                                                   where ca is CustomerAddress &&
                                                       /*AdressTypeID = main office */
                                                   (ca.AddressTypeID == 3  && ca.Address.StateProvince.CountryRegion.Name != countryRegion.Name)
                                                   select ca.Address);
            return storeaddresses;

        }
    }
}
